﻿<!DOCTYPE html>
<!--检维修作业活动工具列表-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" v-cloak class="popupW50">
        <el-row>

            <el-col :span="24">
                <el-form ref="form" :inline="true" label-position="right" label-width="100px" :model="formInline"
                         class="demo-form-inline" style="margin-bottom: 15px;">
                    <el-row>
                        <el-col class="head-tool">

                            <div class="new_title fl">
                                <strong><img src="/static/images/icon1.png" />检维修作业活动工具列表</strong>
                            </div>
                            <span>
                                <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3"
                                     @click="onSubmit"></btn>
                                <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>

                                <btn-template-download tempname="风险检维修作业活动工具模板.xlsx"></btn-template-download>

                                <!--<btn text="导入" linetype="4" @click="ImportDialog=true">{{col.btnImport}}</btn>-->
                                <btn-uploadfile-list url="/api/FX_CheckRepairTool/Import"></btn-uploadfile-list>

                                <btn-export-list url="/api/FX_CheckRepairTool/Export" :forminline="this.formInline" linetype="3">
                                </btn-export-list>
                                <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                            </span>
                        </el-col>
                    </el-row>
                    <el-row>
                        <!--工厂组件-->
                        <list-factorys v-model="formInline.model.CreateFactory" @change="factoryChange"></list-factorys>
                        <!--工具类别-->
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <!--<el-input v-model="formInline.model.ToolType"
                                          :placeholder="InspectionMaintenanceActivitiestool.ToolType" size="mini">
                                    <template slot="prepend">
                                        {{InspectionMaintenanceActivitiestool.ToolType+mark.m}}
                                    </template>
                                </el-input>-->

                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{InspectionMaintenanceActivitiestool.ToolType+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.ToolType" slot="suffix" filterable :placeholder="'工具类别'" @change="ChangeOne">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in ToolTypeList" :label="item.value" :value="item.value"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <!--工具名称-->
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <!--<el-input v-model="formInline.model.ToolName"  :placeholder="InspectionMaintenanceActivitiestool.ToolName" size="mini">
                                    <template slot="prepend">
                                        {{InspectionMaintenanceActivitiestool.ToolName+mark.m}}
                                    </template>
                                </el-input>-->

                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{InspectionMaintenanceActivitiestool.ToolName+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.ToolName" slot="suffix" filterable :placeholder="'工具名称'">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in ToolNameList" :label="item.value" :value="item.value"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <!--风险级别-->
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{InspectionMaintenanceActivitiestool.RiskLevel+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.RiskLevel" slot="suffix"
                                                   :placeholder="InspectionMaintenanceActivitiestool.RiskLevel">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in RiskLevel" :label="item.fxGrade" :value="item.id">
                                            </el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <!--HSE风险-->
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.Risk"
                                              :placeholder="InspectionMaintenanceActivitiestool.Risk" size="mini">
                                        <template slot="prepend">
                                            {{InspectionMaintenanceActivitiestool.Risk+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <!--危害因素-->
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.HazardousFactors"
                                              :placeholder="InspectionMaintenanceActivitiestool.HazardousFactors" size="mini">
                                        <template slot="prepend">
                                            {{InspectionMaintenanceActivitiestool.HazardousFactors+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <!--控制要求-->
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.ControlRequirement"
                                              :placeholder="InspectionMaintenanceActivitiestool.ControlRequirement" size="mini">
                                        <template slot="prepend">
                                            {{InspectionMaintenanceActivitiestool.ControlRequirement+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>

                </el-form>



                <!--<el-col :span="4">
                    <div class="tree_lay">
                        <h4 class="title clearfix"><strong>区域</strong></h4>
                        <el-tree :data="TreeData" show-checkbox node-key="id" ref="tree" highlight-current
                                 @node-click="handleNodeClick">
                            <span slot-scope="scope">
                                <span>
                                    <i :class="scope.data.icon"></i>
                                    <template>
                                        <span v-if="scope.data.icon == 'tree-open'"
                                              style="color:#12489e">{{ scope.node.label }}</span>
                                        <span v-else-if="scope.data.icon == 'tree-close'"
                                              style="color: #12489e">{{ scope.node.label }}</span>
                                        <span v-else>{{ scope.node.label }}</span>
                                    </template>
                                </span>
                            </span>
                        </el-tree>
                    </div>
                </el-col>-->

               
                    <el-table stripe ref="table" :data="ListItem.tableData" :height="ListItem.tableHeight" border
                              @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
                        <el-table-column type="selection" align="center" width="55">
                        </el-table-column>

                        <el-table-column type="index" :label="OperatingProcedures.SerialNumber" :index="indexMethod" align="center"
                                         width="50" show-overflow-tooltip="true"></el-table-column>

                        <!--作业模块-->
                        <el-table-column prop="toolType" :label="InspectionMaintenanceActivitiestool.ToolType" align="center"
                                         min-width="200" show-overflow-tooltip="true">
                        </el-table-column>

                        <!--维修项目-->
                        <el-table-column prop="toolName"
                                         :label="InspectionMaintenanceActivitiestool.ToolName" min-width="180" align="center"
                                         show-overflow-tooltip="true">
                        </el-table-column>



                        <!--HSE风险-->
                        <el-table-column prop="risk" :label="InspectionMaintenanceActivitiestool.Risk" show-overflow-tooltip="true" width="180">
                        </el-table-column>

                        <!--危害因素-->
                        <el-table-column prop="hazardousFactor"
                                         :label="InspectionMaintenanceActivitiestool.HazardousFactors" min-width="320"
                                         show-overflow-tooltip="true">
                        </el-table-column>

                        <!--控制要求-->
                        <el-table-column prop="controlRequirement"
                                         :label="InspectionMaintenanceActivitiestool.ControlRequirement" min-width="300"
                                         show-overflow-tooltip="true">
                        </el-table-column>

                        <!--风险级别-->
                        <el-table-column prop="riskLevelText" :label="InspectionMaintenanceActivitiestool.RiskLevel" show-overflow-tooltip="true" min-width="80" align="center">
                        </el-table-column>


                        <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                            <template slot-scope="scope">
                                <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                                    <i class="el-icon-edit"></i>
                                </button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-row type="flex" justify="end">


                        <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                       :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes"
                                       :page-size="ListItem.pagesize" :layout="ListItem.layout" :total="ListItem.total">
                        </el-pagination>

                    </el-row>
                </el-col>

            
        </el-row>
        <el-dialog title="检维修作业活动工具管理" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%"
                   height="80%" top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
        <delete-select v-model="deleteSelectVisible"
                       :app="this"
                       delete-muti="/api/FX_CheckRepairTool/DeleteMuti"
                       count-url="/api/FX_CheckRepairTool/SelectCount"
                       delete-query-result-url="/api/FX_CheckRepairTool/DeleteSelect">
        </delete-select>
        <!--<el-dialog title="导入" fullscreen="true" :visible.sync="ImportDialog" @close='closeDialog' top="20vh">
        <el-form size="mini" label-position="right">
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                </template>
                                <treeselect v-model="ImportAreaId" :options="TreeData" :flat="true"
                                            slot="suffix" placeholder="请选择区域"
                                            style="line-height: 28px;" />
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" offset="2">
                    <btn-uploadfile-list :data="{data:ImportAreaId}" url="/api/FX_CheckRepairTool/Import"></btn-uploadfile-list>
                </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="ImportDialog = false">{{col.btnBack}}</el-button>
        </div>
    </el-dialog>-->

    </div>
    <script type="text/javascript">
        //Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                     //页面内左树
                    TreeData: [],
                    mydata: RiskControlInformation,

                    ImportAreaId: null,
                    ImportDialog: false,

                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    //////下拉联动////
                    ToolTypeList: [],
                    ToolNameList: [],
                    //////////////////
                    RiskLevel: [],
                    ListItem: ListItem,
                    formInline: {
                        model: {
                            CreateFactory: '',
                            JobModule: '', MaintanenceProject: '',
                            RiskLevel: '', HazardousFactors: '',
                            ControlRequirement: '', Risk: '',
                            JobActivity: '', TreeNode: ''
                            ,AreaIds: []
                        },
                        offset: 0,
                        limit: 10
                    },
                    deleteSelectVisible: false
                }
            },
            //created: function () {
            //    var currApp = this;
            //    window.onresize = function () {
            //        currApp.ListItem.tableHeight = window.innerHeight -
            //            currApp.$refs.table.$el.offsetTop - 60;
            //        if (currApp.ListItem.tableHeight < 112) {
            //            currApp.ListItem.tableHeight = 112;
            //        }
            //    }
            //},
            mounted: function () {
                //this.RiskLevel = getDicData('03');
                this.getRiskLevelList();//调用初始化风险级别
                //初始化数据
                //this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
                //this.TreeData = fn(this.mydata, "0");
                //this.GetTreeData();
                //下拉绑定初始化
                //this.GetLevelOne();
                ////////////////////
                //this.$nextTick(function () {
                //    this.GetPageData(1);
                //    this.GetLevelOne();

                //});
                ///////////////////
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //工厂组件下拉触发
                factoryChange: function () {
                    this.TreeData = GetAreaTreeData(this, this.formInline.model.CreateFactory);
                    this.GetPageData(1);
                    this.GetLevelOne();
                    this.ToolNameList = [];
                },
                //加载一级下拉
                GetLevelOne: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/FXDropDown/InspectionJobActivitiesToolsClass',  this.formInline.model, function (response) {
                        var ajaxModel = response.data;
                        mythis.ToolTypeList = ajaxModel;
                    }, false);
                },
                //一级下拉改变事件，联动二级
                ChangeOne: function () {
                    var mythis = this;
                    //console.log(' this.formInline.model.ToolName', this.formInline.model.ToolName);
                    var factory = this.formInline.model.CreateFactory;
                    if (this.formInline.model.ToolType == null || this.formInline.model.ToolType == '') {
                        return false;
                    }; 
                    myAjax("post", this, '/api/FXDropDown/InspectionJobActivitiesToolsName/' + this.formInline.model.ToolType + '/' + factory, null, function (response) {
                        var ajaxModel = response.data;
                        mythis.ToolNameList = ajaxModel;
                    }, false);
                    this.formInline.model.ToolName = '';
                },
                //导入成功
                successUpload: function () {
                    this.ImportDialog = false;
                },
                //表格序号连续化
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //当前节点如果为最底层的才触发新的查询?暂时先这么处理,如果每层节点都查询就把判断去掉,并在接口逻辑模糊查询
                handleNodeClick: function (data) {
                    if (!data.children) {

                        this.$refs.tree.setCheckedKeys([]);
                        this.$refs.tree.setCheckedKeys([data.id]);
                    } else {
                        this.$refs.tree.setCheckedKeys([]);
                        this.$refs.tree.setCheckedKeys([data.id]);
                        if (data.icon == "tree-open") {
                            data.icon = "tree-close"
                        } else (
                            data.icon = "tree-open"
                        )
                    }
                    this.formInline.model.AreaIds = this.$refs.tree.getCheckedKeys()
                    //onSubmit(this);
                },


              


                closeDialog: function () { closeDialog(this); },
                //删除方法
                //onDelete: function () { onDelete(this, '/api/FX_CheckRepairTool/DeleteMuti'); },
                //删除
                onDelete: function () {
                    this.deleteSelectVisible = true;
                },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "InspectionMaintenanceActivitiesToolInput.html", id); },
                //获取分页数据
                //GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/FX_CheckRepairTool/GetList') },
                GetPageData: function (currentIndex) {
                    //注意：后台约束空值为null  但是Tree id =null时有bug体现在setCheckedKeys 所以只能在扁平化上处理为guidempty，在传给后台前设置为空数组
                    //if (this.formInline.model.AreaIds.length == 1 && this.formInline.model.AreaIds[0] == guidEmpty)
                    //    this.formInline.model.AreaIds = []
                    GetPageData(this, currentIndex, '/api/FX_CheckRepairTool/GetList');
                   // this.GetLevelOne();
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },

                //获取风险级别
                getRiskLevelList: function () {
                    //alert('xxxxxx');
                    var currObj = this;
                    myAjax("post", currObj, '/api/FX_Grade/GetListByGrade', {
                        model: {
                            type: "1",
                        },
                        offset: 0,
                        limit: 100
                    }, function (response) {
                        currObj.RiskLevel = response.data.pageData
                    });
                },


                ///////////////////////////////////////////////////////////////////

            }
        });

        function MenuHelper(list, pid) {
            var result = [];

            list.forEach(function (v, i) {
                if (!v.parentId) v.parentId = guidEmpty;
                if (v.parentId == pid) {
                    var obj = v;
                    obj.id = obj.id + '';
                    obj.label = obj.name + '';
                    obj.icon = 'tree-item';
                    var nextObj = MenuHelper(list, v.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                        obj.icon = 'tree-open';
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>